package com.wnxy.pms.product.core.mapper;

import com.wnxy.pms.product.core.entity.PromotionSeckill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 秒杀活动表 Mapper 接口
 * </p>
 *
 * @author Jet
 * @since 2022-06-06
 */
public interface PromotionSeckillMapper extends BaseMapper<PromotionSeckill> {

    @Select("SELECT id promotionId,product_id productId,ps_count `count` FROM pms_promotion_seckill\n" +
            "WHERE STATUS=#{status} AND NOW()  BETWEEN start_time AND end_time")
    List<Map<String, Object>> selectStoreByStatus(Integer waitStatus);

    @Update("update pms_promotion_seckill set ps_count = ps_count-1 where id = #{value}")
    int updateStore(Integer pormotionId);
}
